<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		请输入答案：<input type="text" onkeypress="fun()" onpaste="check()"/> <br>
		参考答案：4574845185785424587
		<script type="text/javascript">
			function fun(){
				if(event.keyCode<48||event.keyCode>57){
					alert("不允许输入非数字")
					event.preventDefault();
					return;
				}
			}
		</script>
		
		<!-- 用于输出任意键的keyCode -->
		<script type="text/javascript">
			document.body.onkeypress = function(){
				console.log(event.keyCode);
			}
			document.body.oncopy = function(){
				alert("不允许复制答案，自己动手输入!")
				event.preventDefault();
				return;
			}
			function check(){
				alert("不允许粘贴答案，自己动手输入!")
				event.preventDefault();
				return;
			}
		</script>
	</body>
</html>
